package com.thoughtworks.collection;

import sun.reflect.generics.reflectiveObjects.NotImplementedException;

import java.util.*;

public class MyMap {

    List<Integer> array;
    private String[] letters = new String[]{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l",
            "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
    private List<String> letterList = Arrays.asList(letters);

    public MyMap(List<Integer> array) {
        this.array = array;
    }

    public List<Integer> getTriple() {
       List<Integer> list=new ArrayList<>();
       for(int i=0;i<array.size();i++){
           list.add(array.get(i)*3);
       }
       return list;
    }

    public List<String> mapLetter() {
        List<String> list = new ArrayList<>();
        for (int i = 0; i < array.size(); i++) {
            list.add(letters[array.get(i)-1]);
        }
        return list;
    }


    public List<String> mapLetters() {
        List<String> list = new ArrayList<>();
        for (Integer integer : array) {
            String ans = getStr(integer);
            list.add(ans);
        }
        return list;
    }

    private String getStr(Integer integer) {
        String ans = "";
        while(integer > 26){
            ans += "a";
            integer -= 26;
        }
        ans += letters[integer-1];
        return ans;
    }

    public List<Integer> sortFromBig() {
        Collections.sort(array, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2-o1;
            }
        });
        return array;
    }

    public List<Integer> sortFromSmall() {
        Collections.sort(array, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1-o2;
            }
        });
        return array;
    }
}
